package com.ruoyi.web.controller.app.controller;

import com.ruoyi.framework.web.exception.base.XResult;
import com.ruoyi.web.controller.app.request.RequestSendBedEntity;
import com.ruoyi.web.controller.app.service.AppSendRedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

/**
 * @ClassName AppSendBedController
 * @Description TODO
 * @Author tyc@yanyu
 * @Date 2018/12/28 0028 10:57
 **/
@RestController
@RequestMapping("/app/sendred")
@Api(tags = "发送红包")
public class AppSendBedController {
    @Autowired
    private AppSendRedService appSendRedService;

    @PostMapping(value = "userSendRed")
    @ApiOperation( value = "发送红包")
    public XResult userSendRed(RequestSendBedEntity entity) {
        return new XResult("操作成功", appSendRedService.userSendReds(entity));
    }

    @PostMapping(value = "userReceiveRed")
    @ApiOperation( value = "抢红包")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "用户ID号", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "redId", value = "红包ID", required = true, dataType = "String", paramType = "query")
    })
    public XResult userReceiveRed(Long memberId, Integer redId) {
        return new XResult("操作成功", appSendRedService.receiveRed(memberId, redId));
    }

    @PostMapping(value = "getUserByRedId")
    @ApiOperation( value = "查询发送人信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "redId", value = "红包ID", required = true, dataType = "String", paramType = "query")
    })
    public XResult getUserByRedId(Integer redId) {
        return new XResult("操作成功", appSendRedService.getUserByRedId(redId));
    }
}
